package com.igeek.shop.service.login;

import com.igeek.common.utils.MD5Utils;
import com.igeek.shop.dao.BaseDao;
import com.igeek.shop.entity.User;

public class LoginServiceImpl implements LoginService {
	private BaseDao<User> dao = new BaseDao<User>();
	@Override
	public User getUser(User user) {
		String password = MD5Utils.md5(user.getPassword());
		String sql = "select * from user where username = ? and password = ?";
		Object [] params = {user.getUsername(),password};
		Object userByOne = dao.getByOne(sql, params, new User());
		User returnUser = (User) userByOne;
		return returnUser;
	}

	@Override
	public User getUserByCookie(String userName) {
		String sql = "select * from user where username = ?";
		Object [] params = {userName};
		Object userByOne = dao.getByOne(sql, params, new User());
		User returnUser = (User) userByOne;
		return returnUser;
	}

}
